class Solution
{
public:

    int rev(vector<int>& height, int left, int right)
    {
        return (min(height[left], height[right]) * (right - left));
    }

    int maxArea(vector<int>& height)
    {
        int left = 0;
        int right = height.size() - 1;
        int n = height.size();
        int max1 = -1;
        int answer = 0;

        while (left < right)
        {
            max1 = max(max1, rev(height, left, right));
            if (height[left] < height[right])
            {
                left++;
            }
            else
            {
                right--;
            }
        }
        return max1;
    }
};